package com.sicheng.datastruct.linkedlist;
/**
 *
 *  单链表的增删改查
 *  单链表的顺序插入
 */
public class SingleNodeApp {
    public static void main(String[] args) {


        SingleLinkedNode singleNode = new SingleLinkedNode();

        HeroNode node1 = new HeroNode(1, "宋江", "及时雨");
        HeroNode node2 = new HeroNode(2, "宋江", "及时雨");
        HeroNode node3 = new HeroNode(3, "宋江", "及时雨");
        HeroNode node4 = new HeroNode(4, "宋江", "及时雨");
        HeroNode node5 = new HeroNode(5, "宋江", "及时雨");

        singleNode.addByLevel(node5);
        singleNode.addByLevel(node5);


        singleNode.addByLevel(node4);
        singleNode.addByLevel(node3);
        singleNode.addByLevel(node1);
        singleNode.addByLevel(node2);

        singleNode.addByLevel(node1);
        singleNode.addByLevel(node1);
        singleNode.addByLevel(node1);
        singleNode.list();
        System.out.println("=====================");
        singleNode.deleteByNo(1);
        singleNode.deleteByNo(9);
        singleNode.list();

        System.out.println("====================");
        HeroNode node = new HeroNode(1,"林冲","豹子头");
        singleNode.update(node);
        singleNode.list();
        System.out.println(singleNode.count());

        System.out.println("===================");
        if ((node = singleNode.selectTheLastK(4))==null){
            System.out.println("找不到,倒数第k个不存在");
        }else System.out.println(node);

        System.out.println("===================");
        singleNode.reverse();
        singleNode.list();

        Node<String> cirNode = new Node<>("hello");
        System.out.println(cirNode);

        System.out.println("**************************");
        singleNode.reversePrint();

        singleNode.reversePrint();
    }
}
